<style type="text/css">
    div.children_wrapper
    {
    	padding: 10px 10px 10px 30px;
    }
</style>
<?
	$sess = new Zend_Session_Namespace(CLU_NS);
?>
<script type="text/javascript">
var mode = '<?=$this->viewParams['mode']?>';

$(function(){
	
	<?if(isset($this->viewParams['cityId'])) :?>
		$("div.city_address").css('display', 'none');
		$(".cityId").attr('value', <?=$this->viewParams['cityId']?>);
	<?endif?>
	
	<?if(isset($this->viewParams['rtype'])) :?>
		$("div.category").css('display', 'none');
		$(".rtype").attr('value', <?=$this->viewParams['rtype']?>);
	<?endif?>
	
	//city
	$("div#sukien_more_city").find("a").click(function(){
		$("div#sukien_box_right_city_hide").css('display', 'block');
		$("div#sukien_box_right_city_show").css('display', 'none');
		$("div#sukien_more_city").css('display', 'none');
	});
	
	$("div#sukien_less_city").find("a").click(function(){
		$("div#sukien_box_right_city_hide").css('display', 'none');
		$("div#sukien_box_right_city_show").css('display', 'block');
		$("div#sukien_more_city").css('display', 'block');
	});
	
	<?if(!isset($this->viewParams['listDistrict'])) :?>
		$("div#sukien_box_right_district_not_featured").css('display', 'block');
	<?endif?>
	//disitrict
	$("div#sukien_more_district").find("a").click(function(){
		$("div#sukien_box_right_district_not_featured").css('display', 'block');
		$("div#sukien_box_right_district_featured").css('display', 'none');
		$("div#sukien_more_district").css('display', 'none');
	});
	
	$("div#sukien_less_district").find("a").click(function(){
		$("div#sukien_box_right_district_not_featured").css('display', 'none');
		$("div#sukien_box_right_district_featured").css('display', 'block');
		$("div#sukien_more_district").css('display', 'block');
	});
	
	//rtype
	$("div#sukien_more_rtype").find("a").click(function(){
		$("div#sukien_box_right_rtype_hide").css('display', 'block');
		$("div#sukien_box_right_rtype").css('display', 'none');
		$("div#sukien_more_rtype").css('display', 'none');
	});
	
	$("div#sukien_less_rtype").find("a").click(function(){
		$("div#sukien_box_right_rtype_hide").css('display', 'none');
		$("div#sukien_box_right_rtype").css('display', 'block');
		$("div#sukien_more_rtype").css('display', 'block');
	});
	
	//type
	$("div#sukien_more_type").find("a").click(function(){
		$("div#sukien_box_right_type").css('display', 'none');
		$("div#sukien_box_right_type_hide").css('display', 'block');
		$("div#sukien_more_type").css('display', 'none');
	});
	
	$("div#sukien_less_type").find("a").click(function(){
		$("div#sukien_box_right_type_hide").css('display', 'none');
		$("div#sukien_box_right_type").css('display', 'block');
		$("div#sukien_more_type").css('display', 'block');
	});
	
	$('.chooseOtherCity').openDOMWindow({ 
                        height:400, 
                        width:510, 
                        positionType:'centered', 
                        positionTop:100, 
                        eventType:'click', 
                        positionLeft:100, 
                        windowSourceID:'#chooseCity', 
                        windowPadding:10, 
                        /*draggable:1,*/ 
                        windowBGColor:'#FFFFFF', 
                        borderColor:'#24386c',
                        borderSize: '12', 
                        overlayOpacity:40 
                });
                
     $('.chooseOtherCategory').openDOMWindow({ 
                        height:250, 
                        width:510, 
                        positionType:'centered', 
                        positionTop:100, 
                        eventType:'click', 
                        positionLeft:100, 
                        windowSourceID:'#chooseCategory', 
                        windowPadding:5, 
                        /*draggable:1,*/ 
                        windowBGColor:'#FFFFFF', 
                        borderColor:'#24386c',
                        borderSize: '12', 
                        overlayOpacity:40 
                });
                
     $("#list_districtId input:checkbox[name=district_id[]]").click(function(){
     	val = $(this).val();
     	if($(this).is(":checked"))
     	{
     		
     	}
     	else
     	{
     		dis = $('.new_districtId').val();
     		ids = dis + ',' + $(this).val();
     		$(".new_districtId").attr("value", ids);
     	}
     });
     
     $("#list_type input:checkbox[name=type[]]").click(function(){
     	if($(this).is(":checked"))
     	{
     	}
     	else
     	{
     		dis = $('.new_Type').val();
     		ids = dis + ',' + $(this).val();
     		$(".new_Type").attr("value", ids);
     	}
     });
     
     // make less box and more box synchronized between clicks
     $("#sukien_box_right_district_featured input:checkbox").click(function(){
    	id = $(this).attr("value");
    	checked= $(this).attr("checked");
	    $("#sukien_box_right_district_not_featured input:checkbox[value=" + id + "]").attr("checked", checked);
	});

     $("#sukien_box_right_district_not_featured input:checkbox").click(function(){
    	id = $(this).attr("value");
    	checked= $(this).attr("checked");
	    $("#sukien_box_right_district_featured input:checkbox[value=" + id + "]").attr("checked", checked);
	});
	
});



function submit()
{
	document.frmsearch.submit();
}
</script>
<form id="form_id" name="frmsearch" accept-charset="UTF-8" action="<?= $this->escape($this->viewParams['form']->getAction()) ?>"
      method="<?= $this->escape($this->viewParams['form']->getMethod()) ?>">

<div class="box">
   <div class="chitiet_bar">
     <div class="chitiet_bar_left"></div>
     <div class="chitiet_bar_right"><?=t(702)?></div>
   </div>
           <div class="chitiet_content">
           	   <div class="city_address">
               <div class="sukien_box_left">
                     <span>*</span> <?=t(770)?> &nbsp;&nbsp;
               </div>
               <div class="sukien_box_right" id="sukien_box_right_city_show">
               		<?$i = 0;?>
                 	<?foreach ($this->viewParams['listCity'] as $top) :?>
                     <div class="sukien_box_right_item">
							<?if($top['status'] == 'featured') :?>
									<a href="<?=$this->hvnUrl(array('module'=>'place','action' => 'search'), 'nocontroller')
											?>?cluSearch=1&city_id=<?=$top['city_id']?>
											<?if(isset($this->viewParams['categoryId'])) :?>&category=<?=$this->viewParams['categoryId']?><?endif?>
											<?if(isset($this->viewParams['rtype'])) :?>&rtype=<?=$this->viewParams['rtype']?><?endif?>
											<?if(isset($this->viewParams['type'])) :?>
												<?if(is_array($this->viewParams['type'])) :?>
													&type=<?=$this->viewParams['string_type']?>
												<?else:?>
													&type=<?=$this->viewParams['type']?>
												<?endif?>
											<?endif?>
											"><?if($sess->viewLang == 'vi')echo $top['city_name']; else echo VN_unaccent($top['city_name'])?></a>
							<?endif?>
                     </div>
                     <?$i++?><?if($i == 6) :?><?break?><?endif?>
					<?endforeach?>
               </div>    
              <div class="sukien_more" id="sukien_more_city"><a href="javascript:void();"><?=t(150)?></a></div>  
              <div class="sukien_box_right" id="sukien_box_right_city_hide" style="display:none;">
	              <?for ($i = 0; $i < count($this->viewParams['listCity']); $i++) :?>
	                   <div class="sukien_box_right_item">
					   		 <?$top = $this->viewParams['listCity'][$i]?>
								<div class="switch_top_city">
									<a href="<?=$this->hvnUrl(array('module'=>'place','action' => 'search'), 'nocontroller')
											?>?cluSearch=1&city_id=<?=$top['city_id']?>
											<?if(isset($this->viewParams['categoryId'])) :?>&category=<?=$this->viewParams['categoryId']?><?endif?>
											<?if(isset($this->viewParams['rtype'])) :?>&rtype=<?=$this->viewParams['rtype']?><?endif?>
											<?if(isset($this->viewParams['type'])) :?>
												<?if(is_array($this->viewParams['type'])) :?>
													&type=<?=$this->viewParams['string_type']?>
												<?else:?>
													&type=<?=$this->viewParams['type']?>
												<?endif?>
											<?endif?>
											"><?if($sess->viewLang == 'vi')echo $top['city_name']; else echo VN_unaccent($top['city_name'])?></a>
								</div>
	                   </div>
	              <?endfor?>
                 <div class="sukien_less" id="sukien_less_city"><a href="javascript:void();"><?=t(197)?></a></div> 
             </div>   
         	</div>
         <?if(isset($this->viewParams['listDistrict'])) :?>
           <div class="sukien_box_left">
                 <span>*</span> <?=t(771)?> &nbsp;&nbsp;
           </div>
           <div class="sukien_box_right_left">
           	<span>
           		<?if($sess->viewLang == 'vi')echo $this->viewParams['cityName']; else echo VN_unaccent($this->viewParams['cityName'])?></a>
           	</span>
           </div>
           <div class="sukien_box_right_right">
           		<a href="#chooseCity" class="chooseOtherCity" ><?=t(907)?></a>
                <div id="chooseCity" style="display: none;">
                
              <div class="clear"></div>
                 <div class="chitiet_bar_ajax" style="width: 100%">&nbsp;&nbsp;<?=t(907)?></div>
          <br /><br /><br />
   
                	<?for ($i = 0; $i < count($this->viewParams['listCity']); $i++) :?>
		               <div class="sukien_box_right_item">
					   		 <?$top = $this->viewParams['listCity'][$i]?>
								<a href="<?=$this->hvnUrl(array('module'=>'place','action' => 'search'), 'nocontroller')
									?>?cluSearch=1&city_id=<?=$top['city_id']?>
									<?if(isset($this->viewParams['districtId'])):?>&district_id=<?=$this->viewParams['dist_Id']?><?endif?>
									<?if(isset($this->viewParams['categoryId'])) :?>&category=<?=$this->viewParams['categoryId']?><?endif?>
									<?if(isset($this->viewParams['rtype'])) :?>&rtype=<?=$this->viewParams['rtype']?><?endif?>
									<?if(isset($this->viewParams['type'])) :?>&type=<?=$this->viewParams['string_type']?><?endif?>
									"><?if($sess->viewLang == 'vi')echo $top['city_name']; else echo VN_unaccent($top['city_name'])?></a>
		             	  </div>
		          	<?endfor?>
                </div> 
           </div>
           <?endif?>
     		<?if(isset($this->viewParams['listDistrict'])) :?>
	           <div class="sukien_box_right" id="sukien_box_right_district_featured">
	           <?$i = 0;?>
	         	<?foreach ($this->viewParams['listDistrict'] as $dis) :?>
	                 	<div class="sukien_box_right_item" id="list_districtId">
								<input type="checkbox" name="district_id[]" value="<?=$dis['district_id']?>">
									<?if($sess->viewLang == 'vi')echo $dis['district_name']; else echo VN_unaccent($dis['district_name'])?>
								</input>
	                 	</div>
	               <?$i++;?>
	               <?if($i == 6) :?><?break;?><?endif?>
				<?endforeach?>
	           </div>
	         <?if(count($this->viewParams['listDistrict']) > 8 ) :?>
	        	<div class="sukien_more" id="sukien_more_district" style="display:block;"><a href="javascript:void();"><?=t(150)?></a></div>
	        <?endif?>  
			<?endif?>
			<?if(isset($this->viewParams['listDistrict'])) :?>		
            <div class="sukien_box_right" id="sukien_box_right_district_not_featured" style="display:none;">
	         	<?for ($i = 0; $i < count($this->viewParams['listDistrict']); $i++) :?>
					<?$dis = $this->viewParams['listDistrict'][$i];?>
	                 	<div class="sukien_box_right_item" id="list_districtId">
							<input type="checkbox" name="district_id[]" value="<?=$dis['district_id']?>">
								<?if($sess->viewLang == 'vi')echo $dis['district_name']; else echo VN_unaccent($dis['district_name'])?>
							</input>
	                 	</div>
				<?endfor?>
				<div class="sukien_less" id="sukien_less_district"><a href="javascript:void();"><?=t(197)?></a></div>
	           </div>
			<?endif?>
            <div class="clear"></div> 
	           <!-- category-->
	           <div class="box box_margin">
           	   <div class="category">
               <div class="sukien_box_left">
                     <span>*</span> <?=t(779)?> &nbsp;&nbsp;
               </div>
               <div class="sukien_box_right" id="sukien_box_right_rtype">
                 	<?foreach ($this->viewParams['listCategory'] as $k => $category) :?>
                     <div class="sukien_box_right_item">
								<a href="<?=$this->hvnUrl(array('module'=>'place','action' => 'search'), 'nocontroller')
										?>?cluSearch=1<?if(isset($this->viewParams['cityId'])) :?>&city_id=<?=$this->viewParams['cityId']?><?endif?>
										<?if(isset($this->viewParams['dist_Id'])) :?>&district_id=<?=$this->viewParams['dist_Id']?><?endif?>
										&rtype=<?=$category['id']?>
										"><?=p($category['title'])?></a>
                     </div>
                     <?if($k == "_0_1_8"):?><?break?><?endif?>
					<?endforeach?>
               </div>    
              <div class="sukien_more" id="sukien_more_rtype"><a href="javascript:void();"><?=t(150)?></a></div>  
              <div class="sukien_box_right" id="sukien_box_right_rtype_hide" style="display:none;">
	              <?foreach ($this->viewParams['listCategory'] as $category) :?>
                     <div class="sukien_box_right_item">
								<a href="<?=$this->hvnUrl(array('module'=>'place','action' => 'search'), 'nocontroller')
										?>?cluSearch=1&city_id=<?if(isset($this->viewParams['cityId'])) :?><?=$this->viewParams['cityId']?><?endif?>&rtype=<?=$category['id']?>"><?=p($category['title'])?></a>
                     </div>
					<?endforeach?>
                 <div class="sukien_less" id="sukien_less_rtype"><a href="javascript:void();"><?=t(197)?></a></div> 
             </div> 
         	</div>
            <?//die_a($this->viewParams['listType'])?>
     	<?if(isset($this->viewParams['listType'])) :?>
           <div class="sukien_box_left">
                 <span>*</span> <?=t(816)?> &nbsp;&nbsp;
           </div>
           <div class="sukien_box_right_left"><span><?=p($this->viewParams['categoryName']['name'])?></span></div>
           <div class="sukien_box_right_right">
           		<a href="#chooseCategory" class="chooseOtherCategory" ><?=t(908)?></a>
                <div id="chooseCategory" style="display: none;">
                <div class="clear"></div>
                 <div class="chitiet_bar_ajax" style="width: 100%">&nbsp;&nbsp;<?=t(908)?></div>
          <br /><br /><br />
          
                	<?foreach ($this->viewParams['listCategory'] as $category) :?>
                     <div class="sukien_box_right_item">
								<a href="<?=$this->hvnUrl(array('module'=>'place','action' => 'search'), 'nocontroller')
										?>?cluSearch=1&city_id=<?if(isset($this->viewParams['cityId'])) :?><?=$this->viewParams['cityId']?><?endif?>
										<?if(isset($this->viewParams['districtId'])):?>&district_id=<?=$this->viewParams['dist_Id']?><?endif?>
										&rtype=<?=$category['id']?>
										"><?=p($category['title'])?></a>
                     </div>
					<?endforeach?>
                </div> 
           </div>
           <div class="sukien_box_right" id="sukien_box_right_type">
                	<?foreach ($this->viewParams['listType'] as $type) :?>
		               <div class="sukien_box_right_item" id="list_type">
							<input type="checkbox" name="type[]" value="<?=$type['id']?>"><?=p($type['title'])?></input>
	             	  </div>
		          	<?endforeach?>
		    </div>
		    <?if(count($this->viewParams['listType']) > 7 ):?>
	        <div class="sukien_more" id="sukien_more_type"><a href="javascript:void();"><?=t(150)?></a></div>
	        <?endif?>
	        <div class="sukien_box_right" id="sukien_box_right_type_hide" style="display:none;">
                	<?foreach ($this->viewParams['listType'] as $type) :?>
		               <div class="sukien_box_right_item" id="list_type">
							<input type="checkbox" name="type[]" value="<?=$type['id']?>"><?=p($type['title'])?></input>
	             	  </div>
		          	<?endforeach?>
		    <div class="sukien_more" id="sukien_less_type"><a href="javascript:void();"><?=t(197)?></a></div>
		    </div>  
			<?endif?>
				<div class="clear"></div> 
	           <div class="sukien_box_left"><span>*</span> <?=t(906)?>&nbsp;&nbsp;&nbsp;&nbsp;</div>
	           <div class="sukien_box_right" style="border: 0pt none ;">
			           <div class="sukien_box_right_search_left"><?= $this->viewParams['form']->search_name;?></div> 
			           <div  class="sukien_box_right_search_right" align = "right"><a href="javascript:void();" onclick="submit();" > <?=t(627)?>&nbsp;&nbsp;&nbsp;</a></div>
               </div>
	           <div class="clear"></div> 
        </div> 
        </div>
        <div class="clear"></div> 
</div>
<input type="hidden" class="new_districtId" name="remove_district_id" value="" />
<input type="hidden" class="new_Type" name="remove_type" value="" />
<input type="hidden" class="cityId" name="city_id" value="" />
<input type="hidden" class="rtype" name="rtype" value="" />
<input type="hidden" name="cluSearch" value="1" />
</form>    

<script type="text/javascript">
	<?if(isset($this->viewParams['districtId'])):?>
			<?foreach ($this->viewParams['districtId'] as $t) :?>
				$("input:checkbox[name=district_id[]]").filter("[value=<?=$t;?>]").trigger("click");
			<?endforeach?>
	<?endif?>
	<?if(isset($this->viewParams['type'])):?>
		<?if(is_array($this->viewParams['type'])) :?>
			<?foreach ($this->viewParams['type'] as $t) :?>
				$("input:checkbox[name=type[]]").filter("[value=<?=$t;?>]").trigger("click");
			<?endforeach?>
		<?else:?>
			$("input:checkbox[name=type[]]").filter("[value=<?=$this->viewParams['type'];?>]").trigger("click");
		<?endif?>
	<?endif?>
</script>